import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'

// import { get, post } from 'common'

import WujieVue from 'wujie-vue3'
// import WujieVue from 'wujie-vue3-dl'

const { bus } = WujieVue

// 在 xxx-sub 路由下子应用将激活路由同步给主应用，主应用跳转对应路由高亮菜单栏
bus.$on('sub-route-change', (name: string, path: string) => {
  const mainName = `${name}-sub`;
  const mainPath = `/${name}-sub${path}`;
  const currentName = router.currentRoute?.value.name;
  const currentPath = router.currentRoute?.value.path;
  if (mainName === currentName && mainPath !== currentPath) {
    router.push(mainPath)
  }
})

const app = createApp(App)

app.use(createPinia())
app.use(router)

app.use(WujieVue)

app.mount('#app')
